﻿{//信息界面}
<extend name="Public/template/printerbase.html"/>
<block name='header'>
<include file="./Public/template/printernav.html" info="active"/>
</block>
<block name='head'>
</block>
<block name='content'>
<div class="title" >
    <h2>{$data['name']}<small class="School" style="font-type:Arial;font-size:12px;color:#AAAAAA">&nbsp;{$data.account},来自</small></h2>
    <span class='label label-success'><a href="__URL__/logout" style="text-decoration: none; color: #FFFFFF">退出登录</a></span><span class="label label-danger"><a href="mailto:feedback@print.nkumstc.cn" style="text-decoration: none; color: #FFFFFF">认证有误</a></span>
    <br/>
    <br/>
</div>

<div class="container">


<div class="row">
<div class="col-sm-8">
    <section>
        <h4><strong>重置密码</strong><i class='btn glyphicon glyphicon-pencil' id="changePwdCtrl"></i></h4>
        <form  id="changePwd" style="display:none;" role="form" method="post" action="__URL__/changePwd">
                <div class="input-group">
                    <label class="input-group-addon" for="deprecated_password">当前密码</label>
                    <input required="required" class="form-control" placeholder='正在使用的密码' name="deprecated_password" type="password" id="deprecated_password">
                </div>
                 <div class="input-group">
                    <label class="input-group-addon" for="password">新的密码</label>
                    <input class="form-control" placeholder='要设置的密码' name="password" type="password" id="password">
                </div> 
                <div class="input-group">
                    <label class="input-group-addon" for="re_password">确认密码</label>
                    <input  class="form-control" placeholder='重复刚设置的密码' name="re_password" type="password" id="re_password">
                </div>
                <br/>
                 <div class="input-group text-center">
                <button type="submit" class="btn btn-success" id="changePwdButton">确定</button>
                <span class='cancel btn btn-warning'>取消</span>
                </div>
        </form>
    </section>
    <section>
        <h4><strong>信息修改</strong></h4>
        
        <form  id="changeInfo" role="form" method="post" action="__URL__/changeInfo">
            <div class="input-group">
                <label class="input-group-addon"  for="qq">QQ</label>
                <input id="qq" class="form-control" value="{$data['qq']}" name="qq" type="text" pattern="\d{5,}">
            </div>          
            <div class="input-group">
                <label class="input-group-addon"  for="phone">手机</label>
                <input id="phone" class="form-control" value="{$data['phone']}" name="phone" type="text" pattern="1[3458]\d{9}" required>
            </div>
            <div class="input-group">
                <label class="input-group-addon"  for="email">邮箱</label>
                <input id="email" class="form-control" value="{$data['email']}" name="email" type="email">
            </div>
            <div class="input-group">
                <label class="input-group-addon"  for="address">地址</label>
                <input id="address" class="form-control" value="{$data['address']}" placeholder="15字以内" name="address" type="text" required>
            </div>
            <br/>

            <div class="input-group">
                <label class="input-group-addon"  for="open_time">营业时间</label>
                <input id="open_time" class="form-control" value="{$data['open_time']}" placeholder="如：8:00-22:00" name="open_time" type="text" required>
            </div>
            <div class="input-group">
                <label class="input-group-addon"  for="p_s">单面价格（黑白）</label>
                <input id="p_s" type="number" min="0.01" step="0.01" class="form-control" value="{$price['p_s']}" name="p_s" placeholder="如1角每张请填写0.10" required>
                <span class="input-group-addon">元/张</span>
            </div>
            <div class="input-group">
                <label class="input-group-addon" for="p_d">双面价格（黑白）</label>
                <input id="p_d" type="number" min="0.01" step="0.01" class="form-control" value="{$price['p_d']}" name="p_d" placeholder="如1角每张请填写0.10" required>
                <span class="input-group-addon">元/张</span>
            </div>
            <div class="input-group">
                <label class="input-group-addon" for="p_c_s">彩印价格（单面）</label>
                <input id="p_c_s" type="number" min="0.1" step="0.01" class="form-control" value="{$price['p_c_s']}" placeholder="价格可以直接输入" name="p_c_s" required>
                <span class="input-group-addon">元/张</span>
            </div>
            <div class="input-group">
                <label class="input-group-addon" for="p_c_d">彩印价格（双面）</label>
                <input id="p_c_d" type="number" min="0.1" step="0.01" class="form-control" value="{$price['p_c_d']}" placeholder="价格可以直接输入" name="p_c_d" required>
                <span class="input-group-addon">元/张</span>
            </div>          
            <br/>
            <div class="form-group">
                <label for="price_more">优惠信息</label>
                <textarea id="price_more" class="form-control" rows="2" placeholder="如：单面黑白打印过百份7分一张，50字以内" name="price_more">{$data['price_more']}</textarea>
            </div>
            <div class="form-group">
                <label for="profile">打印店简介</label>
                <textarea id="profile" class="form-control" rows="4" placeholder="打印店自我介绍，如详细地址、业务范围等，100字以内" name="profile">{$data['profile']}</textarea>
            </div>
             <div class="input-group text-center">
                <button type="submit" class="btn btn-success" id="changeInfoButton">确定</button>
             </div>
        </form>
    </section>
    
</div>
</div>
</div>
</block>

<BLOCK name='end'>
<script src="__PUBLIC__/js/md5.min.js" type='text/javascript'></script>
<script>

$('#changeInfoButton').attr('disabled',true);


$('.glyphicon-pencil').click(function() {
    var info = $(this).parent();
    info.next().toggle(100);
});

$('.cancel').click(function() {
    var set = $(this).parent().parent();
    set.hide(100);
    set.prev().show(100);
});

$("#changePwd").bind('submit',function() {
    $('#changePwdButton').attr('disabled',true);
    var URL = "__URL__/changePwd"; 
    var deprecated_password = $('#deprecated_password').val();
    var password = $('#password').val();
    var re_password = $('#re_password').val();
    
    if(re_password == password && re_password && password)
    {
        $.post(URL, {
            deprecated_password : md5(deprecated_password),
            password: md5(password),
            isMD5 : 1
        }, function(data) {
            if (data.status) {
                alert(data.info);
                location.href="__URL__/logout";
            } else {
                alert(data.info);
            }
        });
    }
    
    else
    {
        alert("两次密码不一致！");
    }
    $('#changePwdButton').attr('disabled',false);
    $('#deprecated_password').val('');
    $('#password').val('');
    $('#re_password').val('');
    return false;
});


$("#changeInfo").on('submit',function(event) {
    $('#changeInfoButton').attr('disabled',true);
    
    event.preventDefault();
    
    var URL = "__URL__/changeInfo";

    var qq = $('#qq').val();
    var phone = $('#phone').val();
    var address = $('#address').val();
    var profile = $('#profile').val();
    var open_time = $('#open_time').val();
    var email = $('#email').val();
    var p_c_s = $('#p_c_s').val();
    var p_c_d = $('#p_c_d').val();
    var p_s = $('#p_s').val();
    var p_d = $('#p_d').val();
    var price_more = $('#price_more').val();
    
        $.post(URL, {
            qq : qq ,
            phone  : phone ,
            address  : address ,
            profile  : profile ,
            open_time  : open_time ,
            email : email ,
            p_c_s  : p_c_s ,
            p_c_d  : p_c_d ,
            p_s  : p_s ,
            p_d  : p_d ,
            price_more  : price_more
        }, function(data) {
            if (data.status) {
                alert(data.info);
            }
            else
            {
                $('#changeInfoButton').attr('disabled',false);
            }
        });
   });
   
$('input').change(function(){
    $('#changeInfoButton').attr('disabled',false);
});
$('textarea').change(function(){
    $('#changeInfoButton').attr('disabled',false);
});
</script>
</BLOCK>
